#include <iostream>

using namespace std;

int  n;

int check(int x)
{
	int cnt = x, sum = x;
	while(cnt >= 3)
	{
		sum += cnt / 3;
		cnt = cnt / 3 + cnt % 3;
	}
	return sum;
}

int main()
{
	cin >> n;
	int l = n / 2 - 1, r = n;
	while(l < r)
	{
		int mid = (l + r) >> 1;
		if(check(mid) >= n) r = mid;
		else l = mid + 1;
	}

	cout << l << endl;
	return 0;
}
